﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xiaov.SmartWeb.Infrastructure.ExtMethod;

namespace Xiaov.SmartWeb.Application.ZNPT
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            //Xiaov.SmartWeb.Model.ActiveRecord.S_PM_USER model = new Model.ActiveRecord.S_PM_USER();
            //Response.Write(model.GetJsonByCache());
            //Response.End();
            string type = Request.QueryString["type"].ToString();
            if (type == "save")
            {
 
               // string DOCMC =  Request.Params["DOCMC"].ToString();
               // string DOTMC =  Request.Params["DOTMC"].ToString();
               // string DOCZQ =  Request.Params["DOCZQ"].ToString();

               // if (DOCMC != "" && DOTMC != "" && DOCZQ != "")
                {
                  /*  string kzm = System.IO.Path.GetExtension(FilePath).ToLower();//取文件扩展名
                    string time = System.DateTime.Now.ToString("yyyyMMddHHmmssffff");//("yyyy-MM-dd HH:mm:ss:fff");
                    DateTime time1 = DateTime.Now;//这个time是用来传到数据库里的，因为数据库字段类型为datetime型
                    string path = "upvideo/" + time + t3.FileName + kzm;//服务器文件的相对路径,并将文件名称修改为当前时间+名称
                    string fullpath = MapPath(".") + "/" + path;//服务器文件的绝对路径
                    t3.PostedFile.SaveAs(fullpath);//上传文件到绝对路径fullpath，同名文件覆盖，所以文件名很精确

                    string sql = string.Format(@"insert into zn_docbm values('{0}','{1}','{2}','{3}')", System.Guid.NewGuid().ToString(), t2.Text, fullpath, t4.Text);

                    Maticsoft.DBUtility.DbHelperOra.ExecuteSql(sql.ToString());*/
                 //   context.Response.ContentType = "text/plain";  
            //图片名   
                     HttpFileCollection files = Request.Files;
                     if (files.Count > 0)
                     {
                         HttpPostedFile file = files[0];

                         if (file.ContentLength > 0)
                         {
                             //全路径   
                             string FullFullName = file.FileName;
                             //获取图片的名称   
                             String fileName = FullFullName.Substring(FullFullName.LastIndexOf("\\") + 1);
                             //保存路径D:\GoodCommunitySystem2.0 - 副本\GoodCommunitySystem\Paint\img\   
                             string path = "~/Paint/img";
                             file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path) + "\\" + fileName);
                         }  
                     }

                     

                    Response.ContentType = "text/json";
                    Response.Write("1");
                    Response.End();
                }
              
               
                
            }
            else if (type == "load")
            {
                //Xiaov.SmartWeb.Model.ActiveRecord.DWBMB dwModel = new Model.ActiveRecord.DWBMB();
                //List<DWBMB> dwList = dwModel.FindAllByCache().ToList();
                string strSQL = "select * from ZN_DOCBM";
                System.Data.DataTable dt = Maticsoft.DBUtility.DbHelperOra.Query(strSQL).Tables[0];
                //System.Data.DataTable dt = userList.ToDataTable();
                string json = "";
                if (dt != null)
                {
                    json = dt.ToJsonForGrid();
                }
                if (json == "") json = "[]";
                Response.Write(json);
                Response.End();
            }
            else if (type == "del")
            {
                string strBM = Request.Params["DOCBM"].ToString();
                string sql = string.Format(@"delete from zn_docbm where docbm='{0}'", strBM);
                Maticsoft.DBUtility.DbHelperOra.ExecuteSql(sql);
                Response.ContentType = "text/json";
                Response.Write("1");
                Response.End();
            }
          
        }

      
       

    }
}